package cn.stylefeng.guns.modular.business.frequency.orderroyalty.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.orderroyalty.service.OrderRoyaltyService;
import cn.stylefeng.guns.modular.business.frequency.orderroyalty.model.param.OrderRoyaltyParam;

import javax.annotation.Resource;

/**
 * 提成记录表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:16
 */
@RestController
public class OrderRoyaltyController {

    @Resource
    private OrderRoyaltyService orderRoyaltyService;

    /**
     * 分页查询提成记录表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderRoyalty/page")
    @BusinessLog(title = "提成记录表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(OrderRoyaltyParam orderRoyaltyParam) {
        return new SuccessResponseData(orderRoyaltyService.page(orderRoyaltyParam));
    }

    /**
     * 获取全部提成记录表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderRoyalty/list")
    @BusinessLog(title = "提成记录表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(OrderRoyaltyParam orderRoyaltyParam) {
        return new SuccessResponseData(orderRoyaltyService.list(orderRoyaltyParam));
    }

    /**
     * 查看详情提成记录表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderRoyalty/detail")
    @BusinessLog(title = "提成记录表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(OrderRoyaltyParam.detail.class) OrderRoyaltyParam orderRoyaltyParam) {
        return new SuccessResponseData(orderRoyaltyService.detail(orderRoyaltyParam));
    }

    /**
     * 添加提成记录表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderRoyalty/add")
    @BusinessLog(title = "提成记录表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(OrderRoyaltyParam.add.class) OrderRoyaltyParam orderRoyaltyParam) {
        orderRoyaltyService.add(orderRoyaltyParam);
        return new SuccessResponseData();
    }

    /**
     * 删除提成记录表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderRoyalty/delete")
    @BusinessLog(title = "提成记录表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(OrderRoyaltyParam.delete.class) OrderRoyaltyParam orderRoyaltyParam) {
        orderRoyaltyService.delete(orderRoyaltyParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑提成记录表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderRoyalty/edit")
    @BusinessLog(title = "提成记录表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(OrderRoyaltyParam.edit.class) OrderRoyaltyParam orderRoyaltyParam) {
        orderRoyaltyService.edit(orderRoyaltyParam);
        return new SuccessResponseData();
    }

    /**
     * 修改状态
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderRoyalty/changeStatus")
    @BusinessLog(title = "提成记录表_修改状态", opType = LogAnnotionOpTypeEnum.CHANGE_STATUS)
    public ResponseData changeStatus(@RequestBody @Validated(OrderRoyaltyParam.changeStatus.class) OrderRoyaltyParam orderRoyaltyParam) {
        orderRoyaltyService.changeStatus(orderRoyaltyParam);
        return new SuccessResponseData();
    }

}
